﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BlogMVC.ModelEntity;

namespace BlogMVC.Areas.Admin.Controllers
{
    public class ArticleCommentController : Controller
    {
        DataBaseDataContext Dconten = new DataBaseDataContext();
        public ActionResult Index()
        {
            var list = Dconten.ArticleComments.ToList();
            return View(list);
        }

        public ActionResult Details(int id)
        {
            var item = Dconten.ArticleComments.Where(o => o.ArticleCommentId==id).Single();
            return View(item);
        }

        public ActionResult Delete(int id)
        {
            var articleComment = Dconten.ArticleComments.
                                    Where(o => o.ArticleCommentId == id)
                                        .Single();
            return View(articleComment);
        }

        [HttpPost]
        public ActionResult Delete(int id,bool?h)
        {
            try
            {
                var articleComment = Dconten.ArticleComments
                                    .Where(o => o.ArticleCommentId == id)
                                        .Single();
                Dconten.ArticleComments.DeleteOnSubmit(articleComment);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
